package com.gaoqian.chatroom.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;

import java.time.LocalDateTime;
import java.util.Objects;

public class User {
    public Integer uid;
    public String username;
    public String nickname;
    @JsonIgnore
    public String password;
    @JsonFormat(pattern ="yyyy-MM-dd HH-mm-ss" )
    public LocalDateTime logoutAt;

    public User(){}

    public User(Integer uid, String username, String nickname, String password, LocalDateTime logoutAt) {
        this.uid = uid;
        this.username = username;
        this.nickname = nickname;
        this.password = password;
        this.logoutAt = logoutAt;
    }

    @Override
    public String toString() {
        return "User{" +
                "uid=" + uid +
                ", username='" + username + '\'' +
                ", nickname='" + nickname + '\'' +
                ", logoutAt=" + logoutAt +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
       User user = (User) o;
        return uid.equals(user.uid);
    }

    @Override
    public int hashCode() {
        return Objects.hash(uid);
    }
}
